import streamlit as st

def increment_counter():
    st.session_state["counter"] += 1

if __name__ == '__main__':
    # 初始化会话状态
    if "counter" not in st.session_state:
        st.session_state["counter"] = 0
    # 显示当前计数器值
    st.write("计数器值:", st.session_state["counter"])

    # 创建一个按钮，并定义回调函数
    st.button("点击我", on_click=increment_counter)
